home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 March / CMCD0305.ISO / Software / Shareware / Utilitare / emu / Emu8086_Setup_307c.exe / {app} / Samples / param.asm < prev    next >
Assembly Source File  |  2002-08-02  |  1KB  |  61 lines

  1. ; This sample prints out the command
  2. ; line parameters.
  3. ; In DOS you simply add this line
  4. ; after an executable:
  5. ; param.com my parameters
  6. ; In emulator you should set
  7. ; them by selecting "Set command line paramters"
  8. ; from "File" menu of emulator window.
  9.  
  10. #make_COM#
  11.  
  12. ORG     100h
  13.  
  14.  
  15. ; address of command line:
  16. MOV     SI, 80h
  17.  
  18.  
  19. ; copy command line to our buffer:
  20. XOR     CX, CX          ; zero CX register.
  21. MOV     CL, [SI]        ; get command line size.
  22.  
  23. LEA     DI, buffer      ; load buffer address to DI.
  24.  
  25. CMP     CX, 0           ; CX = 0 ?
  26. JZ      no_param        ; then skip the copy.
  27.  
  28. INC     SI              ; copy from second byte.
  29. next_char:
  30. MOV     AL, [SI]
  31. MOV     [DI], AL
  32. INC     SI
  33. INC     DI
  34. LOOP    next_char
  35.  
  36. ; set '$' sign in the end of the buffer:
  37. MOV     BYTE PTR [DI], '$'
  38.  
  39. ; print out the buffer:
  40. LEA     DX, buffer
  41. MOV     AH, 09h
  42. INT     21h
  43.  
  44. JMP     exit    ; skip error message.
  45.  
  46. no_param:
  47. ; print out the error message:
  48. LEA     DX, msg
  49. MOV     AH, 09h
  50. INT     21h
  51. JMP     exit
  52.  
  53. ; exit here:
  54. exit:
  55. RET
  56.  
  57. buffer DB 30 dup (' ')
  58. msg DB 'No command line parameters!', 13, 10, '$'
  59.  
  60. END
  61.